package com.cslg.ac.demo.dao.user.team;

import com.cslg.ac.demo.dao.user.po.team.TeamRecruitPO;
import com.cslg.ac.demo.entity.user.team.TeamRecruit;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.omg.CORBA.INTERNAL;
import org.omg.CORBA.ServerRequest;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;

@Mapper
public interface TeamRecuritDAO {
    static final String E_TABLE_NAME = "e_team_recruit_msg";
    static final String R_TABLE_NAME = "r_team_recruit";
    static final String E_INSERT_FIELDS = "count, work_begin, work_end, work_place ," +
            " work_detail , work_demand , work_attention";
    static final String E_SELECT_FIELDS = "id, count, work_begin workBegin, work_end workEnd," +
            " work_place workPlace, work_detail workDetail, work_demand workDemand, work_attention workAttention";
    static final String R_INSERT_FIELDS = "team_id, recruit_id";

    @Insert({"insert into ", E_TABLE_NAME, "(", E_INSERT_FIELDS ,")", "values(#{count}, #{workBegin}, #{workEnd}, " +
            "#{workPlace}, #{workDetail}, #{workDemand}, #{workAttention})" })
    void insert(TeamRecruitPO teamRecruitPO);

    @Insert({"insert into ", R_TABLE_NAME, "(", R_INSERT_FIELDS, ")"," values(#{param1}, #{param2})"})
    void insertR(@RequestParam("param1")int teamId, @RequestParam("param2")int recruitId);

    @Select({"select ", E_SELECT_FIELDS, "from ", E_TABLE_NAME, "where id = #{id} and status != '1'"})
    TeamRecruitPO selectById(@RequestParam("id")int id);

    @Select({"select recruit_id from ", R_TABLE_NAME, "where team_id = #{param1} limit #{param2}, #{param3}"})
    Integer[] selectByTeam(@RequestParam("param1")int teamId,@RequestParam("param2")int offset, @RequestParam("param3")int num);

    @Select({"select last_insert_id()"})
    Integer selectRecruitId();

}
